package praktikumid.p06_t;

public class Regexp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// regular expression
		
		String email = "email";
		// kas on korrektne?
		
		System.out.println(email.matches("email"));
		System.out.println(email.matches("e...."));
		System.out.println("eesti".matches("e...."));
		System.out.println("eesti".matches("e[asdf]..."));
		System.out.println("eesti".matches("e[a-z]..."));

		System.out.println("eesti".matches("e.{4}"));
		System.out.println("eesti".matches("e[a-z]{4}"));
		// 0 .. inf
		System.out.println("e".matches("e[a-z]*"));
		// 1 .. inf
		System.out.println("e".matches("e[a-z]+"));
		
		// jne
		
		String original = "esimese kodutöö punktid väljas &lt;br&gt; &lt;p&gt;&lt;a target=&quot;_blank&quot; rel=nofollow rel=follow href=&quot;https://docs.google.com/spreadsheet/pub?key=0AnoMCh3_x82sdDlFYTVUMDl2Sk1ZRXJQMmptZUczR2c&amp;single=true&amp;gid=1&amp;output=html&quot;&gt;[link]&lt;/a&gt;";
		String out = original;
		
		// process out
		// &lt; <
		// &gt; >
		// &nbsp; no braking space
		
		/*
		 * &lt;br&gt;
		 * <br>
		 * enter
		 * 
		 * html entites => tavasümbol => html täägide parsimine
		 * 
		 */
		out = out.replace("&lt;", "<");
		out = out.replace("&gt;", ">");
		out = out.replace("&quot;", "\"");
		System.out.println(out);
		// <br> => \n
		// <p> => \n\n
		/*
		 * <a target="_blank" rel=nofollow rel=follow href="https://docs.google.com/spreadsheet/pub?key=0AnoMCh3_x82sdDlFYTVUMDl2Sk1ZRXJQMmptZUczR2c&amp;single=true&amp;gid=1&amp;output=html">[link]</a>
		 * nofollow[link]</a>
		 */
		out = "<a rel=tere><br><a rel=tulemast>";
		//out = out.replaceAll("rel=([a-z]+)", "uus=\"$1\"");
		out = out.replaceAll("<a [^><]*rel=([a-z]+)>", "$1");
		
		System.out.println(out);
	}

}
